package com.stars.easyms.logger.support.tomcat;

import com.stars.easyms.base.util.ReflectUtil;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;

import java.lang.reflect.Constructor;

/**
 * <p>className: EasyMsTomcatEmbeddedLogFactoryHandler</p>
 * <p>description: EasyMs修改内嵌tomcat的处理类</p>
 *
 * @author guoguifang
 * @date 2019-12-27 17:13
 * @since 1.5.0
 */
public final class EasyMsTomcatEmbeddedLogFactoryHandler {

    public static void setDiscoveredLogConstructor() {
        try {
            Constructor<? extends Log> constructor = EasyMsTomcatEmbeddedLog.class.getConstructor(String.class);
            ReflectUtil.writeFinalField(LogFactory.getFactory(), "discoveredLogConstructor", constructor);
        } catch (NoSuchMethodException | IllegalAccessException | NoSuchFieldException e) {
            // ignore
        }
    }

    private EasyMsTomcatEmbeddedLogFactoryHandler() {}

}